package com.antd.admin.server.strategy.data;

import com.antd.admin.api.dto.RoleDTO;
import com.antd.admin.server.service.ISysUserService;
import com.antd.common.auth.util.AntdSecurityUtil;
import com.antd.common.data.enums.DataScopeTypeEnum;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: 冷言丶冷语
 * @create: 2020-10-27 10:48
 */
@Component("2")
public class ThisLevelDataScope implements AbstractDataScopeHandler {
    @Autowired
    private ISysUserService userService;
    @Override
    public List<String> getDeptIds(RoleDTO roleDto, DataScopeTypeEnum dataScopeTypeEnum) {
        String deptId = userService.findByUsername(AntdSecurityUtil.getUsername()).getDeptId();
        return Lists.newArrayList(deptId);
    }
}
